package com.jsy.search.controller;

import com.jsy.common.constant.StatusCode;
import com.jsy.common.vo.Result;
import com.jsy.search.service.PageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/page")
public class PageController {

    @Autowired
    private PageService pageService;

    @RequestMapping("/createHtml/{id}")
    public Result createHtml(@PathVariable Long id) {
        try {
            pageService.createHtml(id);
            return new Result(true, StatusCode.OK, "生成页面成功");
        } catch (Exception e) {
            e.printStackTrace();
        }
        return new Result("生成页面失败");
    }

    @RequestMapping("/deleteHtml/{id}")
    public Result deleteHtml(@PathVariable Long id) {
        try {
            pageService.deleteHtml(id);
            return new Result(true, StatusCode.OK, "删除页面成功");
        } catch (Exception e) {
            e.printStackTrace();
        }
        return new Result("删除页面失败");
    }

}
